@extends('cimo_admin.app')

@section('content')
<link href="{{ asset('/css/spinners.css') }}" rel="stylesheet">
<div id="grid" class="grid" style="position: fixed;z-index: 1000;left:50%;display: none;">
    <div class="cell">
        <div class="card">
            <span class="throbber-loader">Loading…</span>
        </div>
    </div>
</div>
<div class="loading" style=" font-size:20px;text-align:center;display:none;">
    <i class="icon-spinner icon-spin orange bigger-125"></i>
</div>
<ul class="nav nav-tabs">
    <li class="active"><a href="{{ url('/admin/refuel/stores/index')}}">{{$company->name}}-成员列表</a></li>
    {{--<li><a href="{{ url('/admin/enterprise/companys/create') }}">信息添加</a></li>--}}
</ul>

<div class="panel panel-info mt20">
    <div class="panel-heading">筛选</div>
    <div class="panel-body">

    </div>
</div>
<div class="panel panel-default mt20">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
          <thead>
            <tr>
              <th>编号</th>
              <th>成员昵称</th>
              <th>性别</th>
                <th>系统角色</th>
                <th>所属组</th>
              <th>是否组长</th>
              <th>加入时间</th>
            </tr>
          </thead>
          <tbody>
          @foreach($member as $res)
            <tr id="news_{{ $res->id }}">
              <td>{{ $res->id }}</td>
                <td>{{ $res->qw_name }}</td>
                <td>
                    @if($res->gender  == 1)
                        男
                    @elseif($res->gender  == 2)
                        女
                    @else
                        未知
                    @endif
                </td>
                <td>
                    @foreach($res->roles as $r)
                        {{$rolearray[$r->role_id]}}<br/>
                    @endforeach
                </td>
                <td>{{ getGroupName($res->group_id) }}</td>
                <td>
                    @if($res->is_leader  == 1)
                        组长
                    @else
                        组员
                    @endif
                </td>
              <td>{{ date('Y-m-d',strtotime($res->created_at))}}</td>
            </tr>
          @endforeach
          </tbody>
        </table>
    </div>
</div>
<div>{!! $member->render() !!} </div>
<script>
    function changeStore(url,id,val,token)
    {
        //$('#is_stop').css('display', '');
        var datastr = 'id=' + id + '&is_prohibited=' +val;
        $.ajax({
            'url':url,
            'type':'POST',
            'data':datastr+'&_token='+ token,
            success: function(data){
                if(data.status == 'success'){
                    if(data.data == 0){
                        $('#is_stop'+id+' span').attr('class', 'glyphicon glyphicon-ok-circle  green-remove');
                        $('#is_stop'+id+' span').attr('onclick',"changeStore('"+url+"','"+id+"','"+'0'+"','"+token+"')");
                    }
                    else{
                        $('#is_stop'+id+' span').attr('class', 'glyphicon glyphicon-remove-circle red-ok');
                        $('#is_stop'+id+' span').attr('onclick',"changeStore('"+url+"',"+id+","+'1'+",'"+token+"')");
                    }
                    //$('#is-stop').css('display', 'none');
                }

            }
        });
    }

    function changeFamousStore(url,id,val,token)
    {
        //$('#is_stop').css('display', '');
        var datastr = 'id=' + id + '&is_famous=' +val;
        $.ajax({
            'url':url,
            'type':'POST',
            'data':datastr+'&_token='+ token,
            success: function(data){
                if(data.status == 'success'){
                    if(data.data == 1){
                        $('#is_star'+id+' span').attr('class', 'glyphicon glyphicon-ok-circle  green-remove');
                        $('#is_star'+id+' span').attr('onclick',"changeFamousStore('"+url+"','"+id+"','"+'0'+"','"+token+"')");
                    }
                    else{
                        $('#is_star'+id+' span').attr('class', 'glyphicon glyphicon-remove-circle red-ok');
                        $('#is_star'+id+' span').attr('onclick',"changeFamousStore('"+url+"',"+id+","+'1'+",'"+token+"')");
                    }
                    //$('#is-stop').css('display', 'none');
                }

            }
        });
    }

    function changeRecommendStore(url,id,val,token)
    {
        //$('#is_stop').css('display', '');
        var datastr = 'id=' + id + '&is_recommend=' +val;
        $.ajax({
            'url':url,
            'type':'POST',
            'data':datastr+'&_token='+ token,
            success: function(data){
                if(data.status == 'success'){
                    if(data.data == 1){
                        $('#is_recommend'+id+' span').attr('class', 'glyphicon glyphicon-ok-circle  green-remove');
                        $('#is_recommend'+id+' span').attr('onclick',"changeRecommendStore('"+url+"','"+id+"','"+'0'+"','"+token+"')");
                    }
                    else{
                        $('#is_recommend'+id+' span').attr('class', 'glyphicon glyphicon-remove-circle red-ok');
                        $('#is_recommend'+id+' span').attr('onclick',"changeRecommendStore('"+url+"',"+id+","+'1'+",'"+token+"')");
                    }
                    //$('#is-stop').css('display', 'none');
                }

            }
        });
    }
</script>
@endsection
